//
//  EditDataViewController.m
//  MovieDate
//
//  Created by ann on 16/3/13.
//  Copyright © 2016年 MovieDate. All rights reserved.
//

#import "EditDataViewController.h"

#import "PhotosSettingView.h"
#import "AlbumImageModel.h"
#import "AlbumImageView.h"
#import "EditDataViewCell.h"
#import "UserMovieLabelVC.h"

@interface EditDataViewController () <UITableViewDataSource,UITableViewDelegate,PhotosSettingDelegate,UINavigationControllerDelegate,UIActionSheetDelegate,UIImagePickerControllerDelegate>
{
//    //输入框
//    UITextView *_textEditor;
    
    //下拉菜单
    UIActionSheet *myActionSheet;
    
    //图片2进制路径
    NSString* filePath;
    
    PhotosSettingView *viewPics;
    User *user ;
       NSMutableArray *pArrayLabel;
   NSArray *pArrayPlaceholder;
    
}

@property(nonatomic,strong)IBOutlet UIView *pView;

@property (weak, nonatomic) IBOutlet UIView *picImageView;
@property (weak, nonatomic) IBOutlet UITextField *nameTXF;
@property (weak, nonatomic) IBOutlet UITextField *ageTXF;
@property (weak, nonatomic) IBOutlet UITextField *phoneTXF;
@property (weak, nonatomic) IBOutlet UITextView *signMessageTXV;
@property (weak, nonatomic) IBOutlet UILabel *signLB;
@property (strong,nonatomic) AlbumImageView *selectImageView;

@end

@implementation EditDataViewController

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden = NO;
     self.tabBarController.tabBar.hidden = YES;
}

- (void)initInfo
{
    pArrayLabel = [NSMutableArray arrayWithObjects:@"", @"", @"", @"", @"", @"", @"", nil];
    pArrayPlaceholder = [NSArray arrayWithObjects:@"选择你的星座", @"添加你喜欢的美食", @"添加你喜欢的电影", @"添加你喜欢的演员", @"添加你喜欢的导演", @"添加你喜欢的电影类型", @"添加你常去的电影院", nil];
    [self.pView setFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width + 436)];
    [self.pTableView setTableHeaderView:_pView];
    [self.pTableView reloadData];
    
    [self.pTableView setSeparatorStyle:UITableViewCellSeparatorStyleNone];
    self.signMessageTXV.layer.borderWidth = 0.5;
    [self.signMessageTXV.layer setBorderColor:[UIColor colorWithRed:102/255.0f green:102/255.0f blue:102/255.0f alpha:1].CGColor];;

    user = [User defaultUser];
    self.nameTXF.placeholder =   [NSString stringWithFormat:@"%@",user.nickName];
    self.ageTXF.placeholder =  [NSString stringWithFormat:@"%@",user.userAge];
    self.phoneTXF.placeholder =[NSString stringWithFormat:@"%@", user.phone];
    
    NSString *strSign = [NSString stringWithFormat:@"%@",user.signature];
    if (!strSign || [strSign rangeOfString:@"null"].length > 0) {
        self.signMessageTXV.text  = @"这个人很懒,什么都没留下!";
    } else {
        self.signMessageTXV.text  = strSign;
    }
    
    [self selDefaultNavigationBackground];
    [self selDefaultNavigationWithTitle:@"个人信息"];
    [self selAddLeftBackButton];
    [self selAddRightButton:@"完成" imageName:nil selector:@selector(perFormAdd:)];
    
    UIView *view = [[UIView alloc] init];
    [self.pTableView setTableFooterView:view];
    [self initPicImageView];
    
    [self.view setBackgroundColor:[UIColor whiteColor]];
}

///设置背景颜色
- (void)selDefaultNavigationBackground {
    //顶部状态栏图片颜色
    self.navigationController.navigationBar.barTintColor = [UIColor colorWithRed:102/255.0f green:102/255.0f blue:102/255.0f alpha:1.0f];
}

///设置标题
- (void)selDefaultNavigationWithTitle:(NSString *)strTitle {
    NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor], NSForegroundColorAttributeName, [UIFont boldSystemFontOfSize:20], NSFontAttributeName, nil];
    [self.navigationController.navigationBar setTitleTextAttributes:attributes];
    self.title = strTitle;
}

//点击完成按钮
- (void)perFormAdd:(UIButton *)btn
{
  
    user.nickName = self.nameTXF.placeholder;
    if (self.ageTXF.text.length==0) {
        user.userAge = self.ageTXF.placeholder;
    }else{
    user.userAge = self.ageTXF.text;
    }
    user.phone = self.phoneTXF.placeholder;
    user.signature = self.signMessageTXV.text;
    
    self.nameTXF.placeholder = user.nickName;
    self.ageTXF.placeholder = user.userAge;
    self.phoneTXF.placeholder = user.phone;
    self.signMessageTXV.text  = user.signature;
    NSString *identifierForVendor = [[UIDevice currentDevice].identifierForVendor UUIDString];
    [SVProgressHUD show];
    [TDNetwork upDataUserMessagePostUrl:updateUserMessageIP uid:[user.uid integerValue] token:identifierForVendor nickName:user.nickName userSex:user.userSex signature:user.signature userAge:user.userAge movieLabel:user.movieLabel oftenAddress:user.pStrLocationAddress loveMovie:@"" professional:@"" userSkill:@"" complete:^(BOOL succeed, NSString *ret, NSDictionary *dictionary) {
                if (succeed){
                    [TDNetwork updateUserLabel:updateMovieLabel_interface userLabels:pArrayLabel complete:^(BOOL succeed, NSString *ret, NSDictionary *dictionary) {
                        if (succeed) {
                            
                        }else{
                            
                        }
                    }];

                    
                    [SVProgressHUD dismiss];
            } else {
                [SVProgressHUD dismiss];
            }
    }];
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)initPicImageView
{
    [viewPics removeFromSuperview];
    viewPics = nil;
    viewPics = [[PhotosSettingView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width)];
    viewPics.delegate = self;
    [self.picImageView addSubview:viewPics];
    self.picImageView.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.width);
    
    User *user = [User defaultUser];
    __weak typeof(self) weakSelf = self;
    
    [TDNetwork getUserAlbumImagePostUrl:getAlbumImageIP uid:[user.uid integerValue] complete:^(BOOL succeed, NSString *ret, NSDictionary *dictionary) {
        if (succeed) {
            NSArray *arr  = [[dictionary valueForKey:@"res"] valueForKey:@"albumList"];
            for (int i = 0; i < arr.count; i++) {
                NSDictionary *dict = [arr objectAtIndex:i];
                if (dict && [dict isKindOfClass:[NSDictionary class]]) {
                    switch (i) {
                        case 0: {
                            [weakSelf selSetImageInfo:viewPics.pImg1 byDict:dict];
                        }
                            break;
                            
                        case 1: {
                            [weakSelf selSetImageInfo:viewPics.pImg2 byDict:dict];
                        }
                            break;
                            
                        case 2: {
                            [weakSelf selSetImageInfo:viewPics.pImg3 byDict:dict];
                        }
                            break;
                            
                        case 3: {
                            [weakSelf selSetImageInfo:viewPics.pImg4 byDict:dict];
                        }
                            break;
                            
                        case 4: {
                            [weakSelf selSetImageInfo:viewPics.pImg5 byDict:dict];
                        }
                            break;
                            
                        case 5: {
                            [weakSelf selSetImageInfo:viewPics.pImg6 byDict:dict];
                        }
                            break;
                    }
                }
            }
        }
    }];
}

- (void)selSetImageInfo:(AlbumImageView *)image byDict:(NSDictionary *)dict
{
    [image sd_setImageWithURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@/api/common/file/imgGet?fid=%@", IP, [dict objectForKey:@"albumId"]]]];
    [image setContentMode:UIViewContentModeScaleToFill];
    image.albumId = [dict objectForKey:@"albumId"];
    image.albumContent = [dict objectForKey:@"albumContent"];
    image.albumTitle = [dict objectForKey:@"albumTitle"];
    image.uid = [dict objectForKey:@"uid"];
    image.uuid = [dict objectForKey:@"uuid"];
}

#pragma mark -PhotosSettingDelegate
//选择图片事件
-(void)selSelectImg:(AlbumImageView *)imageView {
    imageView.userInteractionEnabled = YES;
    self.selectImageView = imageView;
    //在这里呼出下方菜单按钮项
    myActionSheet = [[UIActionSheet alloc] initWithTitle:nil delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:nil otherButtonTitles: @"删除",@"打开照相机", @"从手机相册获取",nil];
    [myActionSheet showInView:self.view];
}

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex
{
    //呼出的菜单按钮点击后的响应
    if (buttonIndex == myActionSheet.cancelButtonIndex) {
    }
    
    switch (buttonIndex)
    {
        case 0:  //删除图片
            if (_selectImageView.albumId.length > 0) {
                [self deleteImageWithNew:@""];
            }
            break;
            
        case 1:  //打开照相机拍照
            [self takePhoto];
            break;
            
        case 2:  //打开本地相册
            [self LocalPhoto];
            break;
    }
}

//删除图片
-(void)deleteImageWithNew:(NSString *)strJson
{
    [SVProgressHUD show];
    [TDNetwork deleteUserAlbumImagePostUrl:deleteAlbumImageIP albumId:[_selectImageView.albumId integerValue] complete:^(BOOL succeed, NSString *ret, NSDictionary *dictionary) {
        [SVProgressHUD dismiss];
        if (succeed) {
            
            if (strJson.length == 0) {
                _selectImageView.image = [UIImage imageNamed:@"bg"];
                _selectImageView.albumId = @"";
                _selectImageView.albumContent = @"";
                _selectImageView.albumTitle = @"";
                _selectImageView.uid = @"";
                _selectImageView.uuid = @"";
            } else {
                [TDNetwork settingUserAlbumImagePostUrl:settingAlbumImageIP albumJson:strJson complete:^(BOOL succeed, NSString *ret, NSDictionary *dictionary) {
                    if (succeed) {
                        if ([ret intValue] == 1) {
                            [self initPicImageView];
                        }
                    }
                }];
            }
        }
    }];
}

//开始拍照
-(void)takePhoto
{
    UIImagePickerControllerSourceType sourceType = UIImagePickerControllerSourceTypeCamera;
    if ([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeCamera])
    {
        UIImagePickerController *picker = [[UIImagePickerController alloc] init];
        picker.delegate = self;
        //设置拍照后的图片可被编辑
        picker.allowsEditing = YES;
        picker.sourceType = sourceType;
        [self presentModalViewController:picker animated:YES];
    }else{
        NSLog(@"模拟其中无法打开照相机,请在真机中使用");
    }
}

//打开本地相册
-(void)LocalPhoto
{
    NSLog(@"sdasd");
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    
    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
    picker.delegate = self;
    //设置选择后的图片可被编辑
    picker.allowsEditing = YES;
    [self presentModalViewController:picker animated:YES];
}

//当选择一张图片后进入这里
-(void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    NSString *type = [info objectForKey:UIImagePickerControllerMediaType];
    
    //当选择的类型是图片
    if ([type isEqualToString:@"public.image"])
    {
        //先把图片转成NSData
        UIImage* image = [info objectForKey:@"UIImagePickerControllerEditedImage"];
        NSData *data;
        if (UIImagePNGRepresentation(image) == nil)
        {
            data = UIImageJPEGRepresentation(image, 1.0);
        }
        else{
            data = UIImagePNGRepresentation(image);
        }
        
        //图片保存的路径
        //这里将图片放在沙盒的documents文件夹中
        NSString * DocumentsPath = [NSHomeDirectory() stringByAppendingPathComponent:@"Documents"];
        
        //文件管理器
        NSFileManager *fileManager = [NSFileManager defaultManager];
        
        //把刚刚图片转换的data对象拷贝至沙盒中 并保存为image.png
        [fileManager createDirectoryAtPath:DocumentsPath withIntermediateDirectories:YES attributes:nil error:nil];
        [fileManager createFileAtPath:[DocumentsPath stringByAppendingString:@"/image.png"] contents:data attributes:nil];
        
        //得到选择后沙盒中图片的完整路径
        filePath = [[NSString alloc]initWithFormat:@"%@%@",DocumentsPath, @"/image.png"];
        
        self.selectImageView.image = image;
        
        //关闭相册界面
        [picker dismissViewControllerAnimated:YES completion:^{}];
        User *user= [User defaultUser];
        NSData *_data = UIImageJPEGRepresentation(image, 0.5f);
        
        NSString *encodedImageStr = [_data base64Encoding];
        [SVProgressHUD show];
        [TDNetwork uploadingUserPicImagePostUrl:uploadingPicImageIP imgName:[NSString stringWithFormat:@"%@.png",@"xx"] imgData:encodedImageStr title:@"相册图片" type:@"png" complete:^(BOOL succeed, NSString *ret, NSDictionary *dictionary){
            [SVProgressHUD dismiss];
            NSString *fid= [NSString stringWithFormat:@"%@", [[dictionary valueForKey:@"res"] valueForKey:@"fid"]];
            BOOL isAddPic = NO;
            if (viewPics.pImg1.albumId.length == 0) {
                isAddPic = YES;
            } else if (viewPics.pImg2.albumId.length == 0) {
                isAddPic = YES;
            } else if (viewPics.pImg3.albumId.length == 0) {
                isAddPic = YES;
            } else if (viewPics.pImg4.albumId.length == 0) {
                isAddPic = YES;
            } else if (viewPics.pImg5.albumId.length == 0) {
                isAddPic = YES;
            } else if (viewPics.pImg6.albumId.length == 0) {
                isAddPic = YES;
            }
            
            if (isAddPic) {
                [TDNetwork settingUserAlbumImagePostUrl:settingAlbumImageIP albumJson:[NSString stringWithFormat:@"[{\"albumId\":%@,\"uid\":%@,\"albumTitle\":\"%@\",\"albumContent\":\"%@\"}]", fid, user.uid, @"", [NSString stringWithFormat:@"%@", [NSDate date]]] complete:^(BOOL succeed, NSString *ret, NSDictionary *dictionary) {
                    if (succeed) {
                        if ([ret intValue] == 1) {
                            [self initPicImageView];
                        }
                    }
                }];
            } else {
                [self deleteImageWithNew:[NSString stringWithFormat:@"[{\"albumId\":%@,\"uid\":%@,\"albumTitle\":\"%@\",\"albumContent\":\"%@\"}]", fid, user.uid, @"", @""]];
            }
        }];
    }
}

- (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
    [picker dismissModalViewControllerAnimated:YES];
}


#pragma mark  -UITableViewDataSource,UITableViewDelegate

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 7;
}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
    return 1;
}

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *identifer = @"idfEditUserInfoCell";
    EditDataViewCell *cell = [tableView dequeueReusableCellWithIdentifier:identifer];
    if (cell == nil) {
        cell = [[[NSBundle mainBundle]loadNibNamed:@"idfEditUserInfoCell" owner:self options:nil]lastObject];
    }
    switch (indexPath.row) {
            
        case 0:
            cell.titleLB.text = @"星   座";
            for (MovieLabelModel *mlm in user.labels) {
                if ([mlm.type isEqualToString:@"1"]&&![mlm.name isEqualToString:@""]) {
                    
                        cell.contentTXF.text = mlm.name;
                    cell.contentTXF.textColor = [UIColor colorWithRed:254.0/255 green:189.0/255 blue:1.0/255 alpha:1];
                    cell.contentTXF.backgroundColor = [UIColor colorWithRed:255.0/255 green:250.0/255 blue:238.0/255 alpha:1];
                    cell.contentTXF.layer.masksToBounds = YES;
                    cell.contentTXF.layer.cornerRadius = 10;
                }
            }
            cell.contentTXF.placeholder = [pArrayPlaceholder objectAtIndex:0];
            break;
        case 1:
            cell.titleLB.text = @"美   食";
            for (MovieLabelModel *mlm in user.labels) {
                if ([mlm.type isEqualToString:@"2"]&&![mlm.name isEqualToString:@""]) {
                    cell.contentTXF.text = mlm.name;
                    cell.contentTXF.textColor = [UIColor colorWithRed:254.0/255 green:144.0/255 blue:57.0/255 alpha:1];
                    cell.contentTXF.backgroundColor = [UIColor colorWithRed:255.0/255 green:246.0/255 blue:239.0/255 alpha:1];
                    cell.contentTXF.layer.masksToBounds = YES;
                    cell.contentTXF.layer.cornerRadius = 10;
                }
            }
             cell.contentTXF.placeholder = [pArrayPlaceholder objectAtIndex:1];
            break;
        case 2:
            cell.titleLB.text = @"电   影";
            for (MovieLabelModel *mlm in user.labels) {
                if ([mlm.type isEqualToString:@"3"]&&![mlm.name isEqualToString:@""]) {
                    cell.contentTXF.text = mlm.name;
                    cell.contentTXF.textColor = [UIColor colorWithRed:254.0/255 green:0.0/255 blue:2.0/255 alpha:1];
                    cell.contentTXF.backgroundColor = [UIColor colorWithRed:255.0/255 green:238.0/255 blue:238.0/255 alpha:1];
                    cell.contentTXF.layer.masksToBounds = YES;
                    cell.contentTXF.layer.cornerRadius = 10;
                }
            }
             cell.contentTXF.placeholder = [pArrayPlaceholder objectAtIndex:2];
            break;
        case 3:
            cell.titleLB.text = @"演   员";
            for (MovieLabelModel *mlm in user.labels) {
                if ([mlm.type isEqualToString:@"4"]&&![mlm.name isEqualToString:@""]) {
                    cell.contentTXF.text = mlm.name;
                    cell.contentTXF.textColor = [UIColor colorWithRed:195.0/255 green:17.0/255 blue:233.0/255 alpha:1];
                    cell.contentTXF.backgroundColor = [UIColor colorWithRed:252.0/255 green:238.0/255 blue:255.0/255 alpha:1];
                    cell.contentTXF.layer.masksToBounds = YES;
                    cell.contentTXF.layer.cornerRadius = 10;
                }
            }

             cell.contentTXF.placeholder = [pArrayPlaceholder objectAtIndex:3];
            break;
        case 4:
            cell.titleLB.text = @"导   演";
            for (MovieLabelModel *mlm in user.labels) {
                if ([mlm.type isEqualToString:@"5"]&&![mlm.name isEqualToString:@""]) {
                    cell.contentTXF.text = mlm.name;
                    cell.contentTXF.textColor = [UIColor colorWithRed:0.0/255 green:72.0/255 blue:255.0/255 alpha:1];
                    cell.contentTXF.backgroundColor = [UIColor colorWithRed:239.0/255 green:243.0/255 blue:255.0/255 alpha:1];
                    cell.contentTXF.layer.masksToBounds = YES;
                    cell.contentTXF.layer.cornerRadius = 10;
                }
            }

             cell.contentTXF.placeholder = [pArrayPlaceholder objectAtIndex:4];
            break;
        case 5:
            cell.titleLB.text = @"电影类型";
            for (MovieLabelModel *mlm in user.labels) {
                if ([mlm.type isEqualToString:@"6"]&&![mlm.name isEqualToString:@""]) {
                    cell.contentTXF.text = mlm.name;
                    cell.contentTXF.textColor = [UIColor colorWithRed:2.0/255 green:255.0/255 blue:196.0/255 alpha:1];
                    cell.contentTXF.backgroundColor = [UIColor colorWithRed:239.0/255 green:255.0/255 blue:252.0/255 alpha:1];
                    cell.contentTXF.layer.masksToBounds = YES;
                    cell.contentTXF.layer.cornerRadius = 10;
                }
            }

             cell.contentTXF.placeholder = [pArrayPlaceholder objectAtIndex:5];
            break;
        case 6:
            cell.titleLB.text = @"常去影院";
            for (MovieLabelModel *mlm in user.labels) {
                if ([mlm.type isEqualToString:@"7"]&&![mlm.name isEqualToString:@""]) {
                    cell.contentTXF.text = mlm.name;
                    cell.contentTXF.textColor = [UIColor colorWithRed:.0/255 green:255.0/255 blue:0.0/255 alpha:1];
                    cell.contentTXF.backgroundColor = [UIColor colorWithRed:240.0/255 green:255.0/255 blue:200.0/255 alpha:1];
                    cell.contentTXF.layer.masksToBounds = YES;
                    cell.contentTXF.layer.cornerRadius = 10;
                }
            }
             cell.contentTXF.placeholder = [pArrayPlaceholder objectAtIndex:6];
            break;
    }
    
    return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
    UIStoryboard *logStoyBoard = [UIStoryboard storyboardWithName:@"Login" bundle:nil];
    EditDataViewCell *cell = [tableView cellForRowAtIndexPath:indexPath];
    UserMovieLabelVC  *userMovieLabelVC = [logStoyBoard instantiateViewControllerWithIdentifier:@"movieLabelVC"];
    [userMovieLabelVC returnText:^(NSString *showText, NSInteger index,NSString *uuid, NSArray *array) {
        UITextField *textFD = cell.contentTXF;
        if (showText) {
            textFD.text = showText;
            [self.pTableView reloadData];
            [pArrayLabel replaceObjectAtIndex:index-1 withObject:uuid];
            switch (index-1) {
                case 0:
                    textFD.textColor = [UIColor colorWithRed:254.0/255 green:189.0/255 blue:1.0/255 alpha:1];
                    textFD.backgroundColor = [UIColor colorWithRed:255.0/255 green:250.0/255 blue:238.0/255 alpha:1];
                    textFD.layer.masksToBounds = YES;
                    textFD.layer.cornerRadius = 10;
                    break;
                case 1:
                    textFD.textColor = [UIColor colorWithRed:254.0/255 green:144.0/255 blue:57.0/255 alpha:1];
                    textFD.backgroundColor = [UIColor colorWithRed:255.0/255 green:246.0/255 blue:239.0/255 alpha:1];
                    textFD.layer.masksToBounds = YES;
                    textFD.layer.cornerRadius = 10;
                    
                    break;
                case 2:
                    
                    textFD.textColor = [UIColor colorWithRed:254.0/255 green:0.0/255 blue:2.0/255 alpha:1];
                    textFD.backgroundColor = [UIColor colorWithRed:255.0/255 green:238.0/255 blue:238.0/255 alpha:1];
                    textFD.layer.masksToBounds = YES;
                    textFD.layer.cornerRadius = 10;
                    break;
                case 3:
                    textFD.textColor = [UIColor colorWithRed:195.0/255 green:17.0/255 blue:233.0/255 alpha:1];
                    textFD.backgroundColor = [UIColor colorWithRed:252.0/255 green:238.0/255 blue:255.0/255 alpha:1];
                    textFD.layer.masksToBounds = YES;
                    textFD.layer.cornerRadius = 10;
                    break;
                case 4:
                    textFD.textColor = [UIColor colorWithRed:0.0/255 green:72.0/255 blue:255.0/255 alpha:1];
                    textFD.backgroundColor = [UIColor colorWithRed:239.0/255 green:243.0/255 blue:255.0/255 alpha:1];
                    textFD.layer.masksToBounds = YES;
                    textFD.layer.cornerRadius = 10;
                    break;
                case 5:
                    textFD.textColor = [UIColor colorWithRed:2.0/255 green:255.0/255 blue:196.0/255 alpha:1];
                    textFD.backgroundColor = [UIColor colorWithRed:239.0/255 green:255.0/255 blue:252.0/255 alpha:1];
                    textFD.layer.masksToBounds = YES;
                    textFD.layer.cornerRadius = 10;
                    break;
                case 6:
                    textFD.textColor = [UIColor colorWithRed:.0/255 green:255.0/255 blue:0.0/255 alpha:1];
                    textFD.backgroundColor = [UIColor colorWithRed:240.0/255 green:255.0/255 blue:200.0/255 alpha:1];
                    textFD.layer.masksToBounds = YES;
                    textFD.layer.cornerRadius = 10;
                    break;
                    
    }
        }
    }];
    switch (indexPath.row) {
        case 0:
            userMovieLabelVC.pNavTitle = @"星座";
            [self.navigationController pushViewController:userMovieLabelVC animated:YES];
            break;
        case 1:

            userMovieLabelVC.pNavTitle = @"美食";
            [self.navigationController pushViewController:userMovieLabelVC animated:YES];
            break;
        case 2:
            userMovieLabelVC.pNavTitle = @"电影";
            [self.navigationController pushViewController:userMovieLabelVC animated:YES];
                   break;
        case 3:
            userMovieLabelVC.pNavTitle = @"演员";
            [self.navigationController pushViewController:userMovieLabelVC animated:YES];
      
            break;
        case 4:
            userMovieLabelVC.pNavTitle = @"导演";
            [self.navigationController pushViewController:userMovieLabelVC animated:YES];
  
            break;
        case 5:
            userMovieLabelVC.pNavTitle = @"电影类型";
            [self.navigationController pushViewController:userMovieLabelVC animated:YES];
      
            break;
        case 6:
            userMovieLabelVC.pNavTitle = @"常去影院";
            [self.navigationController pushViewController:userMovieLabelVC animated:YES];
            break;
    }
}
@end
